package com.wzh.service;

import com.wzh.dao.RouterDao;
import com.wzh.pojo.Po.Treemenu;
import com.wzh.pojo.Resp.DataResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RouterService {

	@Autowired
	private RouterDao routerDao;

	public DataResp<Object> show() {

		DataResp<Object> resp=new DataResp<>();
		List<Treemenu> list= routerDao.find();
		if (list.size()!=0){
			resp.setData(list);
			resp.setMes("查询成功！");
		}else{
			resp.setMes("查询失败！");
		}
		return  resp;

	}

	public DataResp<Object> add(Treemenu router) {
		DataResp<Object> resp=new DataResp<>();
		Integer code =routerDao.add(router);

		if (code>0){
			resp.setMes("操作成功！");
		}else {
			resp.setMes("操作失败！");
		}
		return  resp;

	}

	public DataResp<Object> del(Treemenu router) {
		DataResp<Object> resp=new DataResp<>();
		Integer code =routerDao.del(router);

		if (code>0){
			resp.setMes("操作成功！");
		}else {
			resp.setMes("操作失败！");
		}
		return  resp;

	}

}
